package com.example.tms.mapper;

import com.example.tms.bean.WaybillVMgmt;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Slice;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface WaybillVMapper extends JpaRepository<WaybillVMgmt,String> ,JpaSpecificationExecutor<WaybillVMgmt> {



    Page<WaybillVMgmt> findAll(Specification<WaybillVMgmt> spec, Pageable pageable);

    //查询运单信息（运单id）
    @Query(value = "select * from account where ydid = ?1 and sfcz = true", nativeQuery = true)
    WaybillVMgmt findByYdid(String ydid);

    //查询运单信息（运单id）
    @Query(value = "select * from account where sfcz = ?1 and ydzt in ('待调度','待发车','已发车','调度_审核中','订单_审核中') ", nativeQuery = true)
    List<WaybillVMgmt> findDdBysfcz(Boolean sfcz);

    @Query(value = "select * from account where sfcz = ?1 and ydzt in ('已发车','已回车','登记_审核中','已完成','已报账') ", nativeQuery = true)
    List<WaybillVMgmt> findDjBysfcz(Boolean sfcz);

    @Query(value = "select * from account where sfcz = ?1 and ydzt in ('已回车','已完成','报账_审核中','已发车','已报账') ", nativeQuery = true)
    List<WaybillVMgmt> findBzBysfcz(Boolean sfcz);

    @Query(value = "select * from account where sfcz = ?1 and ydzt in ('快捷_已报','快捷_审核中' ) ", nativeQuery = true)
    List<WaybillVMgmt> findKjBysfcz(Boolean sfcz);

    @Query(value = "select * from account where sfcz = ?1  ", nativeQuery = true)
    List<WaybillVMgmt> findAllBysfcz(Boolean sfcz);
}
